mruby 4.0.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
throw.h File Reference

More...

#include <setjmp.h>
Include dependency graph for throw.h:

Go to the source code of this file.

Classes

struct  mrb_jmpbuf

Macros

#define MRB_SETJMP   setjmp
#define MRB_LONGJMP   longjmp
#define MRB_TRY(buf)
#define MRB_CATCH(buf)
#define MRB_END_EXC(buf)
#define MRB_THROW(buf)
#define mrb_jmpbuf_impl   jmp_buf

Detailed Description

  • mruby exception throwing handler

See Copyright Notice in mruby.h

WARNING: This header is for mruby core internal use only. Do not include this header in user code or mrbgems.

When MRB_USE_CXX_EXCEPTION is defined, this header requires C++ compilation. C source files that include this header will fail to compile when linked into C++ projects using MRB_USE_CXX_EXCEPTION.

For exception-safe code in mrbgems and user code, use the mrb_protect_error() API from <mruby/error.h> instead:

#include <mruby/error.h>

mrb_value my_func_body(mrb_state *mrb, void *data) { // code that may raise exceptions return result; }

void my_func(mrb_state *mrb) { mrb_bool error; mrb_value result = mrb_protect_error(mrb, my_func_body, data, &error); // cleanup code runs here regardless of exception if (error) mrb_exc_raise(mrb, result); }

Macro Definition Documentation

◆ MRB_CATCH

#define MRB_CATCH ( buf)
Value:
} else {

◆ MRB_END_EXC

#define MRB_END_EXC ( buf)
Value:
}

◆ MRB_THROW

#define MRB_THROW ( buf)
Value:
MRB_LONGJMP((buf)->impl, 1);

◆ MRB_TRY

#define MRB_TRY ( buf)
Value:
if (MRB_SETJMP((buf)->impl) == 0) {